package com.atguigu.gulimall.product.config;

import com.atguigu.gulimall.product.interfactor.MyInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @Author learner
 * @Create 2023/12/24 21:24
 * @Version 1.0
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    
    @Autowired
    MyInterceptor myInterceptor;
    
    /**
     * 这个方法用来注册拦截器，我们自己写好的拦截器要通过这里添加注册才能生效
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(myInterceptor)
                .addPathPatterns("/product/interceptor/hello")
                .addPathPatterns("/product/category/list/tree");
    }
}
